package com.oocl.util.ipml;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.oocl.modle.Message;

public class FileLoader {
	
	
	public static Message[] loadFile(String file) throws IOException{
		BufferedReader br = new BufferedReader(new FileReader(file));
		String[] result = null;
		List<Message> list = new ArrayList<Message>();
		String temp = null;
		while((temp = br.readLine())!=null){
			list.add(new Message(temp));
		}
		
		Message[] messages = new Message[list.size()];
		for (int i = 0; i < messages.length; i++) {
			messages[i] = list.get(i);
		}
		return messages;
	}
}
